From bbf5dda8b12a8fa01f434a6b9cc362af9a4b9383 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Thu, 17 May 2018 16:24:49 +0200 Subject: [PATCH] babl-palette: fix regression in prefvious commit The 255.5 factor for storing a double represenation is neccesary for desired behavior. --- babl/babl-palette.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/babl/babl-palette.c b/babl/babl-palette.c index 94d214d..a22ea58 100644 --- a/babl/babl-palette.c +++ b/babl/babl-palette.c @@ -222,7 +222,7 @@ rgba_to_pal (Babl *conversion, } } - ((double *) dst)[0] = best_idx / 255.0; + ((double *) dst)[0] = best_idx / 255.5; src += sizeof (double) * 4; dst += sizeof (double) * 1; @@ -278,7 +278,7 @@ rgba_to_pala (Babl *conversion, } } - ((double *) dst)[0] = best_idx / 255.0; + ((double *) dst)[0] = best_idx / 255.5; ((double *) dst)[1] = alpha; src += sizeof (double) * 4; @@ -298,7 +298,7 @@ pal_to_rgba (Babl *conversion, assert(pal); while (n--) { - int idx = (((double *) src)[0]) * 255.0; + int idx = (((double *) src)[0]) * 255.5; double *palpx; if (idx < 0) idx = 0; @@ -325,7 +325,7 @@ pala_to_rgba (Babl *conversion, assert(pal); while (n--) { - int idx = (((double *) src)[0]) * 255.0; + int idx = (((double *) src)[0]) * 255.5; double alpha = (((double *) src)[1]); double *palpx; -- 2.30.2